@extends('admin.layout.common')
@section('content')
    <link rel="stylesheet" href="{{url('/css/finance/FinancialAccountingCenter.css')}}">
    <div class="content">
                <h1 class="h1">财务记账中心</h1>
                <!-- 公共结束 -->
                <div class="center_box">
                    <label for="">选择年份：</label>
                    <select name="" id="" onchange="request(this)">
                        @if($search)
                            @foreach($search as $v)
                            <option value="{{$v->year}}" @if($v->year == $selected) selected @endif>{{$v->year}}</option>
                            @endforeach
                        @endif
                    </select>
                    <table border="1">
                        <tr>
                            <th>收入ID</th>
                            <th>月份</th>
                            <th>总成本</th>
                            <th>明细</th>
                        </tr>
                        @if($data)
                            @foreach($data as $k => $v)
                            <tr>
                                <td>{{$k + 1}}</td>
                                <td>{{$v->month}}</td>
                                <td>{{$v->total}}</td>
                                <td>
                                    <a href="{{url('/admin/costStatisticsCheck')}}?year={{$selected}}&month={{$v->month}}"><button type="button" value="" class="chakan">查看</button></a>
                                </td>
                            </tr>
                            @endforeach
                        @endif
                    </table>
                </div>
            </div>
    <script src="{{url('/js/finance/FinancialAccountingCenter.js')}}"></script>
    <script>
      function request(obj) {
        let value = $(obj).val()
        if (value) {
          window.location.href = '{{url('/admin/costStatistics')}}' + '?year=' + value;
        }
      }
    </script>
@endsection